package com.yixun.qfbao.hander;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yixun.qfbao.api.service.AreaService;
import com.yixun.qfbao.apidto.GetAreaReqDto;
import com.yixun.qfbao.apidto.GetAreaResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetAreaReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * 获取市区
 * @author guifang.weng
 * @create 2017-11-23 13:48
 **/
@Service("getAreaHander")
public class GetAreaHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetAreaHander.class);

    @Autowired
    private AreaService areaService;
    
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        BaseResponseDTO<GetAreaResDto> res = new BaseResponseDTO<>();
        GetAreaReqVo reqVo = (GetAreaReqVo) reqDto;
        GetAreaReqDto getAreaReqDto = reqVo.getParams();
        try {
        	GetAreaResDto resDto = new GetAreaResDto();
			resDto = areaService.getArea(getAreaReqDto);
            res.setResult(resDto.getResult());
            res.setResData(resDto);
        } catch (Exception e) {
            logger.error("GetAreaHander error: {}", e);
            res.setResult(ResultEnum.FAIL.getNo());
            res.setErrorMsg("获取市区列表失败");
        }
        return res;
    }
}
